// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: cilium/api/accesslog.proto

package cilium

import (
	"bytes"
	"errors"
	"fmt"
	"net"
	"net/mail"
	"net/url"
	"regexp"
	"sort"
	"strings"
	"time"
	"unicode/utf8"

	"google.golang.org/protobuf/types/known/anypb"
)

// ensure the imports are used
var (
	_ = bytes.MinRead
	_ = errors.New("")
	_ = fmt.Print
	_ = utf8.UTFMax
	_ = (*regexp.Regexp)(nil)
	_ = (*strings.Reader)(nil)
	_ = net.IPv4len
	_ = time.Duration(0)
	_ = (*url.URL)(nil)
	_ = (*mail.Address)(nil)
	_ = anypb.Any{}
	_ = sort.Sort
)

// Validate checks the field values on KeyValue with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *KeyValue) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on KeyValue with the rules defined in
// the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in KeyValueMultiError, or nil
// if none found.
func (m *KeyValue) ValidateAll() error {
	return m.validate(true)
}

func (m *KeyValue) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	// no validation rules for Key

	// no validation rules for Value

	if len(errors) > 0 {
		return KeyValueMultiError(errors)
	}

	return nil
}

// KeyValueMultiError is an error wrapping multiple validation errors returned
// by KeyValue.ValidateAll() if the designated constraints aren't met.
type KeyValueMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m KeyValueMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m KeyValueMultiError) AllErrors() []error { return m }

// KeyValueValidationError is the validation error returned by
// KeyValue.Validate if the designated constraints aren't met.
type KeyValueValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e KeyValueValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e KeyValueValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e KeyValueValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e KeyValueValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e KeyValueValidationError) ErrorName() string { return "KeyValueValidationError" }

// Error satisfies the builtin error interface
func (e KeyValueValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sKeyValue.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = KeyValueValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = KeyValueValidationError{}

// Validate checks the field values on HttpLogEntry with the rules defined in
// the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *HttpLogEntry) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on HttpLogEntry with the rules defined
// in the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in HttpLogEntryMultiError, or
// nil if none found.
func (m *HttpLogEntry) ValidateAll() error {
	return m.validate(true)
}

func (m *HttpLogEntry) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	// no validation rules for HttpProtocol

	// no validation rules for Scheme

	// no validation rules for Host

	// no validation rules for Path

	// no validation rules for Method

	for idx, item := range m.GetHeaders() {
		_, _ = idx, item

		if all {
			switch v := interface{}(item).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, HttpLogEntryValidationError{
						field:  fmt.Sprintf("Headers[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, HttpLogEntryValidationError{
						field:  fmt.Sprintf("Headers[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return HttpLogEntryValidationError{
					field:  fmt.Sprintf("Headers[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

	// no validation rules for Status

	for idx, item := range m.GetMissingHeaders() {
		_, _ = idx, item

		if all {
			switch v := interface{}(item).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, HttpLogEntryValidationError{
						field:  fmt.Sprintf("MissingHeaders[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, HttpLogEntryValidationError{
						field:  fmt.Sprintf("MissingHeaders[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return HttpLogEntryValidationError{
					field:  fmt.Sprintf("MissingHeaders[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

	for idx, item := range m.GetRejectedHeaders() {
		_, _ = idx, item

		if all {
			switch v := interface{}(item).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, HttpLogEntryValidationError{
						field:  fmt.Sprintf("RejectedHeaders[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, HttpLogEntryValidationError{
						field:  fmt.Sprintf("RejectedHeaders[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return HttpLogEntryValidationError{
					field:  fmt.Sprintf("RejectedHeaders[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

	if len(errors) > 0 {
		return HttpLogEntryMultiError(errors)
	}

	return nil
}

// HttpLogEntryMultiError is an error wrapping multiple validation errors
// returned by HttpLogEntry.ValidateAll() if the designated constraints aren't met.
type HttpLogEntryMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m HttpLogEntryMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m HttpLogEntryMultiError) AllErrors() []error { return m }

// HttpLogEntryValidationError is the validation error returned by
// HttpLogEntry.Validate if the designated constraints aren't met.
type HttpLogEntryValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e HttpLogEntryValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e HttpLogEntryValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e HttpLogEntryValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e HttpLogEntryValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e HttpLogEntryValidationError) ErrorName() string { return "HttpLogEntryValidationError" }

// Error satisfies the builtin error interface
func (e HttpLogEntryValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sHttpLogEntry.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = HttpLogEntryValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = HttpLogEntryValidationError{}

// Validate checks the field values on KafkaLogEntry with the rules defined in
// the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *KafkaLogEntry) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on KafkaLogEntry with the rules defined
// in the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in KafkaLogEntryMultiError, or
// nil if none found.
func (m *KafkaLogEntry) ValidateAll() error {
	return m.validate(true)
}

func (m *KafkaLogEntry) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	// no validation rules for CorrelationId

	// no validation rules for ErrorCode

	// no validation rules for ApiVersion

	// no validation rules for ApiKey

	if len(errors) > 0 {
		return KafkaLogEntryMultiError(errors)
	}

	return nil
}

// KafkaLogEntryMultiError is an error wrapping multiple validation errors
// returned by KafkaLogEntry.ValidateAll() if the designated constraints
// aren't met.
type KafkaLogEntryMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m KafkaLogEntryMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m KafkaLogEntryMultiError) AllErrors() []error { return m }

// KafkaLogEntryValidationError is the validation error returned by
// KafkaLogEntry.Validate if the designated constraints aren't met.
type KafkaLogEntryValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e KafkaLogEntryValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e KafkaLogEntryValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e KafkaLogEntryValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e KafkaLogEntryValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e KafkaLogEntryValidationError) ErrorName() string { return "KafkaLogEntryValidationError" }

// Error satisfies the builtin error interface
func (e KafkaLogEntryValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sKafkaLogEntry.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = KafkaLogEntryValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = KafkaLogEntryValidationError{}

// Validate checks the field values on L7LogEntry with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *L7LogEntry) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on L7LogEntry with the rules defined in
// the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in L7LogEntryMultiError, or
// nil if none found.
func (m *L7LogEntry) ValidateAll() error {
	return m.validate(true)
}

func (m *L7LogEntry) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	// no validation rules for Proto

	// no validation rules for Fields

	if len(errors) > 0 {
		return L7LogEntryMultiError(errors)
	}

	return nil
}

// L7LogEntryMultiError is an error wrapping multiple validation errors
// returned by L7LogEntry.ValidateAll() if the designated constraints aren't met.
type L7LogEntryMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m L7LogEntryMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m L7LogEntryMultiError) AllErrors() []error { return m }

// L7LogEntryValidationError is the validation error returned by
// L7LogEntry.Validate if the designated constraints aren't met.
type L7LogEntryValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e L7LogEntryValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e L7LogEntryValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e L7LogEntryValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e L7LogEntryValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e L7LogEntryValidationError) ErrorName() string { return "L7LogEntryValidationError" }

// Error satisfies the builtin error interface
func (e L7LogEntryValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sL7LogEntry.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = L7LogEntryValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = L7LogEntryValidationError{}

// Validate checks the field values on LogEntry with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *LogEntry) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on LogEntry with the rules defined in
// the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in LogEntryMultiError, or nil
// if none found.
func (m *LogEntry) ValidateAll() error {
	return m.validate(true)
}

func (m *LogEntry) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	// no validation rules for Timestamp

	// no validation rules for IsIngress

	// no validation rules for EntryType

	// no validation rules for PolicyName

	// no validation rules for ProxyId

	// no validation rules for CiliumRuleRef

	// no validation rules for SourceSecurityId

	// no validation rules for DestinationSecurityId

	// no validation rules for SourceAddress

	// no validation rules for DestinationAddress

	switch v := m.L7.(type) {
	case *LogEntry_Http:
		if v == nil {
			err := LogEntryValidationError{
				field:  "L7",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetHttp()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, LogEntryValidationError{
						field:  "Http",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, LogEntryValidationError{
						field:  "Http",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetHttp()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return LogEntryValidationError{
					field:  "Http",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *LogEntry_Kafka:
		if v == nil {
			err := LogEntryValidationError{
				field:  "L7",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetKafka()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, LogEntryValidationError{
						field:  "Kafka",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, LogEntryValidationError{
						field:  "Kafka",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetKafka()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return LogEntryValidationError{
					field:  "Kafka",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *LogEntry_GenericL7:
		if v == nil {
			err := LogEntryValidationError{
				field:  "L7",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetGenericL7()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, LogEntryValidationError{
						field:  "GenericL7",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, LogEntryValidationError{
						field:  "GenericL7",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetGenericL7()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return LogEntryValidationError{
					field:  "GenericL7",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	default:
		_ = v // ensures v is used
	}

	if len(errors) > 0 {
		return LogEntryMultiError(errors)
	}

	return nil
}

// LogEntryMultiError is an error wrapping multiple validation errors returned
// by LogEntry.ValidateAll() if the designated constraints aren't met.
type LogEntryMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m LogEntryMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m LogEntryMultiError) AllErrors() []error { return m }

// LogEntryValidationError is the validation error returned by
// LogEntry.Validate if the designated constraints aren't met.
type LogEntryValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e LogEntryValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e LogEntryValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e LogEntryValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e LogEntryValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e LogEntryValidationError) ErrorName() string { return "LogEntryValidationError" }

// Error satisfies the builtin error interface
func (e LogEntryValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sLogEntry.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = LogEntryValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = LogEntryValidationError{}
